import type { EpPropMergeType } from "element-plus/es/utils/vue/props/types";

//节点复用逻辑
export default {
  props: {
    config: {
      type: Object,
      default: () => {
        return {};
      }
    },
    mode: {
      type: String,
      default: "normal" //组件模式，free设计模式，normal 编辑模式, read 阅读模式，disable 禁用模式
    },
    active: {
      type: Object
    }
  },
  emits: ["copy", "delete"]
};

export type DesignerRefItem = {
  validate(): Promise<void>;
};

export const CONDITIONS_TYPE = [
  {
    label: "等于",
    value: "eq"
  },
  {
    label: "包含",
    value: "like"
  },
  {
    label: "不等于",
    value: "neq"
  },
  {
    label: "不包含",
    value: "nlike"
  },
  {
    label: "大于",
    value: "gt"
  },
  {
    label: "大于等于",
    value: "ge"
  },
  {
    label: "小于",
    value: "lt"
  },
  {
    label: "小于等于",
    value: "le"
  }
];

export type DesignerRefs = {
  _ref: string;
  name: string;
  status: string;
};

export type FormModel = {
  id: string;
  formName: string;
  formRemark: string;
  formStatus: string;
  formInfo: string;
  formTypeId?: string;
  formTypeCode?: string;
  formTypeName?: string;
  storageType?: string;
};

export type FormDesignerModel = {
  conf: {
    //标签位置
    labelPosition: EpPropMergeType<
      StringConstructor,
      "right" | "top" | "left",
      unknown
    >;
    //标签宽度，
    labelWidth: number;
    size: EpPropMergeType<
      StringConstructor,
      "large" | "default" | "small",
      unknown
    >;
  };
  components: FormDesignerComponents[];
};

export type FormDesignerField = {
  tableName: string;
  tableComment: string;
  components: FormDesignerComponents[];
  children: FormDesignerField[];
};

export type FormDesignerComponents = {
  id: string;
  code: string;
  name: string;
  type: string;
  icon?: string;
  props: {
    isContainer: boolean;
    isFormItem: boolean;
    isSubform?: boolean;
    required?: boolean;
    hideLabel?: boolean;
    placeholder?: string;
    multiple?: boolean;
    showBorder?: boolean;
    columns?: any[];
    validate?: string[];
    rows?: number;
    maxlength?: number;
    //分栏组件专有
    span?: number;
    number?: number;
    gutter?: number;
    //评分组件专有属性
    icon?: string;
    showScore?: boolean;
    enableHalf?: boolean;
    color?: string;
    //数字输入组件专有属性
    min?: number;
    max?: number;
    precision?: number;
    //日期时间组件专有属性
    format?: string;
    //表格组件专有属性
    height?: number;
    converts?: any[];
    //唯一编码组件属性
    codetype?: string;
    //文件上传组件专有属性
    accept?: string[];
    limit?: number;
    size?: number;
    //字典选择组件属性
    dictCode?: string;
    showAll?: string;
    exclude?: string[];
    options?: any[];
    optionType?: string;
    optionUrl?: string;
    optionLabel?: string;
    optionValue?: string;
    expanding?: boolean;
    // 部门选择和人员选择
    defaultLogin?: boolean;
    //栅格
    offset?: number;
    push?: number;
    pull?: number;
    //按钮
    type?: EpPropMergeType<
      StringConstructor,
      "primary" | "success" | "warning" | "danger" | "info",
      unknown
    >;
    circle?: boolean;
    action?: ButtonAction;
    event?: FormDesignerComponentEvent;
    //文字提示
    placement?: EpPropMergeType<
      StringConstructor,
      | "top"
      | "top-start"
      | "top-end"
      | "bottom"
      | "bottom-start"
      | "bottom-end"
      | "left"
      | "left-start"
      | "left-end"
      | "right"
      | "right-start"
      | "right-end",
      unknown
    >;
  };
};

export type ButtonAction = {
  // 0: 弹框显示功能列表页；1：弹框显示功能表单页；2：执行onClick
  type: string;
  moduleId: string;
  moduleName: string;
};

export type FormDesignerComponentEvent = {
  onClick?: string;
};

export type MultiTagsItem = {
  id: string;
  text: string;
  type: string;
};

export type FormItemPerm = {
  formId: string;
  fieldCode: string;
  tableKey: string;
  tableComment: string;
  columnKey: string;
  columnComment: string;
  permType: string;
  displayType: string;
  mainSubRadio: string;
};

export type FormColumn = {
  columnName: string;
  columnKey: string;
  columnComment: string;
};
